<?php


namespace app\api\controller;


use app\BaseController;
use think\facade\Db;

class Activity extends BaseController
{

    public function getActivity(){
        /**
        CREATE TABLE `activity` (
        `activity_id` int(11) NOT NULL,
        `date1` datetime DEFAULT NULL,
        `date2` datetime DEFAULT NULL,
        `contents` text,
        PRIMARY KEY (`activity_id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

        --
        -- 转存表中的数据 `activity`
        --

        INSERT INTO `activity` (`activity_id`, `date1`, `date2`, `contents`) VALUES
        (1, '2022-11-14 16:16:18', '2022-11-15 23:59:59', '112');

         **/
        $data  = request()->param();
        $res = Db::table("activity")->where('activity_id',$data['activity_id'])->find();
        if($res){
            return json(['status'=>200,'msg'=>'ok','data'=>$res]);
        }

    }
    public function updateActivity(){
        $data = request()->param();

        $res = Db::table("activity")->where('activity_id',$data['activity_id'])->update($data);
        if($res){
            return json(['status'=>200,'msg'=>'ok']);
        }else{
            return json(['status'=>500,'msg'=>'fail']);
        }

    }
}